#include<stdio.h>
struct date
{
	int year;
	int month;
	int day;
};
int p(int k )
{
	if(k%4==0&&k%100!=0||k%400==0)
	{
		return 1;
	}
	else
	return 0;
}
int fun(struct date m)
    {
    	int a[12]={31,28,31,30,31,30,31,31,30,31,30,31};
    	int i,sum=0; 
    	for(i=0;i<m.month-1;i++)
    	{
    		sum=sum+a[i];
		}
		sum=sum+m.day;
		if(p(m.year)==1)
		sum++;
		return sum;
    }
int main()
{
	struct date m;
	scanf("%d%d%d",&m.year,&m.month,&m.day);
	printf("%d",fun(m));
	return 0;
}
